package com.fary.core;

import java.beans.PropertyChangeEvent;

public class SpringException extends RuntimeException {

	private PropertyChangeEvent propertyChangeEvent;

	public SpringException(Object msg) {
		super(msg.toString());
	}

	public SpringException(Object msg, Throwable cause) {
		super(msg.toString(), cause);
	}

	public SpringException(PropertyChangeEvent propertyChangeEvent, String msg, Throwable cause) {
		super(msg, cause);
		this.propertyChangeEvent = propertyChangeEvent;
	}

	public String getPropertyName() {
		return (this.propertyChangeEvent != null ? this.propertyChangeEvent.getPropertyName() : null);
	}

	/**
	 * Return the affected value that was about to be set, if any.
	 */
	public Object getValue() {
		return (this.propertyChangeEvent != null ? this.propertyChangeEvent.getNewValue() : null);
	}

	/**
	 * Return a corresponding error code for this type of exception.
	 */
	public String getErrorCode() {
		return "";
	}

}
